package com.xxgc.vfc.modules.consumer.score.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.xxgc.vfc.api.result.Result;
import com.xxgc.vfc.api.service.IScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Sjy
 * @Date :2023/10/20 - 10 - 20 - 9:28
 */
@SaCheckLogin//首先你得登陆
@Api(tags = "分数相关")
@Controller
@RestController
@RequestMapping("/score")
public class ScoreController {

    @DubboReference(
            interfaceClass = IScoreService.class,
            check = false,
            version = "0.0.1"//版本号必须与服务提供者版本
    )
    private IScoreService iScoreService;

    private static int num = 0;

    @ApiOperation(value = "获取分数信息")
    @GetMapping("/getMsg")
    public Result getMsg(){
        num++;
        System.out.println("我被调用了"+num+"次");

        return Result.ok().msg("Hello Spring Cloud Alibaba");
    }

    //查询某个人今年的高考分数
    @GetMapping("/getUserScoreById")
    public Result getUserScoreById(){
        Integer scoreByUserId = iScoreService.getScoreByUserId(1);
        return Result.ok(scoreByUserId);
    }

    @SaCheckRole("lpl")
    @ApiOperation(value = "获取自己在LPL中的战绩")
    @GetMapping("/getLPLRecord")
    public Result getLPLRecord(){
        return Result.ok(100);
    }

    @SaCheckRole("lck")
    @ApiOperation(value = "获取自己在LCK中的战绩")
    @GetMapping("/getLCKRecord")
    public Result getLCKRecord(){
        return Result.ok(10);
    }

}
